﻿using System;
using System.Collections;

namespace Student
{

    //作业2：输入班级人数，输入每个人的学号，姓名、语，数，英成绩进入集合
    //求语文的总分，数学的平均分，英语的最高分的人的姓名
    //（使用ArrayList）
    //数据：学号 姓名 语文 数学 英语   
    //1	乔峰	85	 42	  67
    //2	段誉	94	 34	  46
    //3	虚竹	99	 99	  99

    class Program
    {
        static void Main(string[] args)
        {
            Student  a = new Student(1, "乔峰", 85, 42, 67);
            Student a1 = new Student(2, "段誉", 94, 34, 46);
            Student a2 = new Student(3, "虚竹", 99, 99, 99);

            ArrayList A = new ArrayList();

            A.Add(a);
            A.Add(a1);
            A.Add(a2);

            for (int i = 0; i < A.Count; i++)
            {
                if (A[i] is Student)
                {
                    Student B = (Student)A[i];
                    Console.WriteLine("学号{0},姓名{1},语文{2},数学{3},英语{4}", B.stuNo, B.stuName, B.Chinese, B.Math, B.English);
                }

            }
            //语文总分
            double sum = 0;
            for (int i = 0; i < A.Count; i++)
            {
                if (A[i] is Student)
                {
                    Student B = (Student)A[i];
                    sum += B.Chinese;
                }
            }
            Console.WriteLine("语文总分为:{0}", sum);

            //数学平均分
            double avg = 0;

            for (int i = 0; i < A.Count; i++)
            {
                if (A[i] is Student)
                {
                    Student B = (Student)A[i];
                    avg += B.English;
                }
            }
            Console.WriteLine("数学平均分为:{0}", avg / 3);

            //英语最高分
            double max = 0;
            for (int i = 0; i < A.Count; i++)
            {                
                if (A[i] is Student)
                {                    
                    Student B = (Student)A[i];
                    if (B.English > max)
                    {
                        max = B.English;
                    }
                }                           
            }
            Console.WriteLine("英语最高分为:{0}", max);



        }
    }
}